/***************************************************************************
 *   Copyleft 2008-2009 by												   *
 *	 Iwanicki Krzysztof													   *
 *   <gamma.mini.pw.edu.pl/~iwanickik>			                           *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 ***************************************************************************/
#ifndef __VSETUPDIALOG_H__
#define __VSETUPDIALOG_H__


#include "./vAbstractModalDialog.h"
#include "../../Utils/vString.h"
#include "../../Framework/Renderer/vDeviceInfo.h"
#include "../../Macros/vMemoryMacros.h"
#include <commctrl.h>

namespace Vendetta {
	/*! \class ConfigurationDialog
	*   \brief A ConfigurationDialog for application configuration parameters.
	*
	*	Used to set/change dfault parameters for application.
	*
	*	\sa AbstractModalDialog.
	*/
	class vSetupDialog: public vAbstractModalDialog {
	public:
		/*! \brief Parameter constructor.
		*
		*	\param	HINSTANCE	hInstance	Handle to application instance with use current dialog.
		*	\param	HWND		hOwnerWnd	Window parent of the dialog.
		*/
		vSetupDialog(HINSTANCE hInstance, HWND hWndOwner);

		/*! \brief Default constructor.
		*
		*/
		vSetupDialog();

		/*! \brief Destructor.
		*
		*/
		~vSetupDialog();

		/*! \brief Exec dialog, shows and returns execution code.
		*
		*	\return	vInt	Exec value from DialogBox WinAPI function.
		*/
		vInt Exec(vDeviceInfo* devInfoPtr);

		/*! \brief Returns valid DeviceInfo pointer.
		*
		*	\return		DeviceInfo pointer.
		*/
		vDeviceInfo* DeviceInfoPtr();

		/*! \brief Returns whether save configuration or not.
		*
		*	\return		True if configuration should be saved, false otherwise.
		*/
		vBool SaveConfig() const;

	private:
		enum eMenuItemState {
			VMIS_NORMAL,
			VMIS_HOVER,
			VMIS_SELECTED
		};

	private:
		static LRESULT CALLBACK dialogProc(HWND hwnd, UINT, WPARAM, LPARAM);

		vVoid initFields(HWND hDlg);

		vVoid refresh(HWND hDlg);

		vBool isValid();

		vVoid onMouseMove(vSetupDialog::eMenuItemState *eIsInProc, 
			vSetupDialog::eMenuItemState *eIsInScr, HWND hDlg, WPARAM wParam, LPARAM lParam);

		vVoid onLeftButtonDown(vSetupDialog::eMenuItemState *eIsInProc, 
			vSetupDialog::eMenuItemState *eIsInScr, HWND hDlg, WPARAM wParam, LPARAM lParam);

		vVoid onCommand(HWND hDlg, WPARAM wParam, LPARAM lParam);

		vVoid onVideoChanged(HWND hDlg, WPARAM wParam, LPARAM lParam);

		vVoid onColorChanged(HWND hDlg, WPARAM wParam, LPARAM lParam);

		vVoid onFreqChanged(HWND hDlg, WPARAM wParam, LPARAM lParam);

		vVoid onFullScreenChanged(HWND hDlg, WPARAM wParam, LPARAM lParam);

		vVoid onVSynChanged(HWND hDlg, WPARAM wParam, LPARAM lParam);

		vVoid onGPUChanged(HWND hDlg, WPARAM wParam, LPARAM lParam);

		vVoid fillResolution(HWND hDlg, vBool bFirstTime = false, vBool bRefresh = true);

		vVoid fillParam(HWND hDlg, vInt iParID, const vString& paramName);

		vVoid setParams(HWND hDlg, vBool bScreen);

		vVoid clearComboBox(HWND hDlg, vInt iId);

	private:
		static vSetupDialog* mpSetupDialog;
		static HINSTANCE mhInstance;
		vDeviceInfo* mpDeviceInfo;
		vBool mShouldSaveConfig;
		vBool mScreenPanel;
	};
}

#endif // __VSETUPDIALOG_H__